package com.zh.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import com.zh.common.BaseResponse;
import com.zh.common.ResultUtils;
import com.zh.domain.vo.statistics.StatisticsVo;
import com.zh.service.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Api(tags = "StatisticsController", value = "统计控制器")
@RestController
@RequestMapping("/statistics")
@Slf4j
@SaCheckLogin
public class StatisticsController {
    @Resource
    private StatisticsService statisticsService;

    @GetMapping("/week")
    @ApiOperation(value = "weekTaskTrend", notes = "本周任务完成趋势")
    public BaseResponse<StatisticsVo> getWeekTaskTrend(@RequestParam Integer projectId) {
        StatisticsVo statisticsVo = statisticsService.getWeekTaskTrend(projectId);
        return ResultUtils.success(statisticsVo);
    }

    @GetMapping("/all")
    @ApiOperation(value = "getStatisticsAll", notes = "本项目我的全部统计")
    public BaseResponse<StatisticsVo> getStatisticsAll(@RequestParam Integer teamId, @RequestParam Integer projectId) {
        StatisticsVo statisticsVo = statisticsService.getProjectStatisticsAll(teamId, projectId);
        return ResultUtils.success(statisticsVo);
    }

    @GetMapping("/current")
    @ApiOperation(value = "getStatisticsCurrent", notes = "本项目我的当前事项统计")
    public BaseResponse<StatisticsVo> getStatisticsCurrent(@RequestParam Integer projectId) {
        StatisticsVo statisticsVo = statisticsService.getProjectStatisticsCurrent(projectId);
        return ResultUtils.success(statisticsVo);
    }
}
